
<template>
    <div class="model-form">
        <el-page-header @back="goBack" content="更新新闻">
        </el-page-header>
        <div class="model-content">
            <el-form ref="ruleForm" :rules="rules" :model="form" label-width="160px">
                <el-row :gutter="10">
    <el-col :span="22">
            <el-form-item label="标题"  prop="title">
        <el-input v-model="form.title" name="title">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="22">
            <el-form-item label="图片"  prop="logo">
        <avatar v-model="form.logo"></avatar>
            </el-form-item>

    </el-col>
    <el-col :span="22">
            <el-form-item label="视频"  prop="videoUrl">
        <avatar v-model="form.videoUrl"></avatar>
            </el-form-item>

    </el-col>
    <el-col :span="22">
            <el-form-item label="新闻分类"  prop="newsCatalog">
        <el-select style="width: 100%;" v-model="form.newsCatalog" filterable clearable
                   placeholder="请选择">
            <el-option v-for="item in newsCatalogOptions" :key="item.id"
                       :label="item.name" :value="item.id">
            </el-option>
        </el-select>
            </el-form-item>

    </el-col>
    <el-col :span="22">
            <el-form-item label="摘要"  prop="introduce">
        <el-input v-model="form.introduce" name="introduce" type="textarea"></el-input>
            </el-form-item>

    </el-col>
    <el-col :span="22">
            <div style="margin-left: 160px;">
                <sc-editor v-model="form.note" placeholder="请输入" style="width: 100%;"  :height="400"></sc-editor>
            </div>

    </el-col>

                    <el-col :span="22">
                        <el-form-item>
                            <el-button @click="goBack">取消</el-button>
                            <el-button type="primary" @click="updateData">确定</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
    </div>
</template>

<script setup>
    import {defineAsyncComponent} from "vue";
    const scEditor = defineAsyncComponent(() => import('@/components/scEditor/index.vue'));
    import avatar from "@/components/avatar.vue";
import {ref} from "vue";
import {useData} from "@/utils/useData";
import {useUpdate} from "@/uses/useUpdate";

const form = ref({
     title: '',
     logo: '',
     videoUrl: '',
     newsCatalog: '',
     introduce: '',
     note: ''})

const rules = ref({
})

const ruleForm = ref(null);
const{listData:newsCatalogOptions}= useData("/newsCatalog/list")

const {updateData,goBack}=useUpdate("news",form,ruleForm)

</script>

<style scoped>

</style>